package leetcode.leetcode100;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class generateParenthesis {
    public static void main(String[] args) {
        int n =3;
        System.out.println(process(3));
    }
    public static List<String> process(int n){
        List<String> list = new ArrayList<String>();
        process(3,3,list,"");
        return list;
    }
    public static void process(int left,int right,List<String> list,String str ){
        if (left == 0 && right == 0){
            list.add(str);
            return;
        }
        if (left >right){
            return;
        }
       if (right > 0){
           process(left,right-1,list,str + ")");
       }
       if ( left > 0 ){
           process(left-1,right,list,str + "(");
        }
    }
}
